package com.example.demo.controller;


import com.example.demo.dao.CertificateDao;
import com.example.demo.dao.RegisterDao;
import com.example.demo.entity.CertificateEneity;
import com.example.demo.entity.RegisterEntity;
import com.example.demo.service.impl.CertificateServiceImpl;
import com.example.demo.util.EndDateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class PageController {

    @Autowired
    private CertificateDao certificateDao;

    @Autowired
    private RegisterDao registerDao;

    @RequestMapping("/page")
    public String  test (String id , Model model){
      CertificateEneity certificateEneity = certificateDao.queryCertificate(id);
      RegisterEntity registerEntity = registerDao.selectBySerialNumber(id);
      String URL = "/images/"+registerDao.selectUrl(id);
      model.addAttribute("url",URL);
      model.addAttribute("name",certificateEneity.getName());
      model.addAttribute("age",certificateEneity.getAge());
      model.addAttribute("industry",certificateEneity.getIndustry());
      model.addAttribute("sex",certificateEneity.getSex());
      model.addAttribute("serialNumber",certificateEneity.getSerialNumber());
      model.addAttribute("date", EndDateUtil.getDate(certificateEneity.getRegisterDate()));
      model.addAttribute("company",registerEntity.getCompany());
    return "TestPage" ;
}

}




